React Native - Native Android
This page describes how to setup the Grouplink SDK on the native Android folders of a React-Native project.
React Native - Android
Requirements
- Download and install the latest JDK
- Required software:
- Android Studio IDE
- Android SDKs for developing Android apps.
Installing “Android Studio IDE”
Refer to the official Android Studio installation documentation.
-
(Windows)
- Assure that the environment variable JAVA_HOME is set to the correct JDK installation directory via command “set JAVA_HOME” or the windows control panel.
- Verify that the development machine meets the system requirements for Android Studio/SDK.
- Download and install android studio. About 3-4 GB of free disk space is required.
-
(MacOS)
- Verify that the development machine meets the system requirements for Android Studio/SDK
- Download and install android studio. About 3-4 GB of free disk space is required.
- OS X may display a warning that the package is damaged and should be moved to the trash. In that case, under Preferences/Security & Privacy/Allow applications downloaded from, select "Anywhere".
1 - Required Permissions
First, you need to add the required permissions to your Android manifest file (you can find this file inside the android/app/src folder). You can follow the Required Permissions on Android guide to learn more.
2 - Starting BLE and Location Service on Android
Create an asynchronous function and add the methods startLocationAndroid()
and startBluetoothAndroid()
.
export default function App() {
useEffect(() => {
...
requestAndroidPermissions();
}, []);
async function requestAndroidPermissions() {
await GroupLinkSDK.startLocationAndroid();
await GroupLinkSDK.startBluetoothAndroid();
}
return (
<View style={styles.container}>
<Text>This is a test application</Text>
</View>
);
}
3 - Full Screen Intent and Schedule Exact Alarm Permissions
export default function App() {
useEffect(() => {
...
GroupLinkSDK.requestFullIntentPermissionAndroid();
GroupLinkSDK.requestScheduleExactAlarmPermissionAndroid();
}, []);
return (
<View style={styles.container}>
<Text>This is a test application</Text>
</View>
);
}